#pragma once
#include <unordered_map>
#include <string>
#include "base/core/singleton.h"
#include "Scene/Map.h"
#include <list>
#include "SceneMgr.h"
#include "base/core/object_pool.h"

class MapMgr : public ManualSingleton<MapMgr>
{
    friend class ManualSingleton<MapMgr>;
protected:
	typedef std::unordered_map<uint32_t, Map*>             DataMap;
	typedef std::unordered_map<std::string, navMeshInfo> NavMeshMap;

    DataMap  m_mapMap;
	NavMeshMap   m_mapNavMesh;
	ObjectPool<Map> *m_pMapPool;

    bool LoadConfig();
	bool AddMap(uint32_t m_id, Map* map);
    void DelMap(uint32_t m_id);

public:
    bool Init();
    void UnInit();
	Map* GetMap(uint32_t m_id);
	bool IsDynamic(uint32_t mapId);

	void AddNavMeshInfo(std::string& navName, navMeshInfo& navInfo);
	navMeshInfo* GetNavMeshInfo(std::string& navName);

	DataMap* GetAllMaps();

    MapMgr();
    ~MapMgr();
};

#define  g_MakeMapMgr() (MapMgr::Instance())
#define  g_GetMapMgr()  (MapMgr::GetInstance())
#define  g_DelMapMgr()  (MapMgr::Destroy())
